import {axiosLogin} from '../index'
//获取角色列表
export function getRoles(){
  return axiosLogin({
      url:'/roles',
      method:'get'
  })
}
//增加权限列表
export function addRoles(roleName,roleDesc){
 return axiosLogin({
     url:'/roles',
     method:'post',
     data:{
        roleName,
        roleDesc
     }
 })
}
//获取用户权限列表数据
export function getRolesId(id){
  return axiosLogin({
      url:`/roles/${id}`,
      method:'get',
      params:{
          id
      }
  }) 
}
//将编辑的权限用户数据保存到数据库中
export function saveRoles(id,roleName,roleDesc){
  return axiosLogin({
      url:`/roles/${id}`,
      method:'put',
      data:{
        roleName,
        roleDesc
      }
  })
}
//删除权限列表
export function delRolesId(id){
  return axiosLogin({
      url:`/roles/${id}`,
      method:'delete',
      data:{
          id
      }
  })    
}
//删除权限列表children 中对应的权限
export function delRolesItem(roleId,rightId){
  return axiosLogin({
      url:`roles/${roleId}/rights/${rightId}`,
      method:'delete',
  })    
}
//获取所有权限列表
export function getPermissions(type){
  return axiosLogin({
      url:`rights/${type}`,
      method:'get'
  })
}
//为角色分配权限
export function setPermissions(roleId,rids){
  return axiosLogin({
      url:`roles/${roleId}/rights`,
      method:'post',
      data:{
        roleId,
        rids
      }
  })
}